package com.lemon.smartsafety.ui.adapter.profile;

import android.support.annotation.NonNull;

import com.lemon.smartsafety.entity.user.ProfileBaseModel;
import com.lemon.smartsafety.ui.adapter.common.SectionHeadView;
import com.lemon.smartsafety.utils.common.LoggerHelper;

import java.util.List;

import kale.adapter.CommonRcvAdapter;
import kale.adapter.item.AdapterItem;

/**
 * Created by Cooliean on 16/1/17.
 */
public class ProfileAdapter extends CommonRcvAdapter<ProfileBaseModel> {
    private LoggerHelper loggerHelper = new LoggerHelper(ProfileAdapter.class);


    private List<ProfileBaseModel> mItems;

    public ProfileAdapter(List<ProfileBaseModel> mItems) {
        super(mItems);
        this.mItems = mItems;
    }

    @Override
    public Object getItemType(ProfileBaseModel profileBaseModel) {
        return profileBaseModel.getViewType();
    }

    @NonNull
    @Override
    public AdapterItem createItem(Object type) {
        ProfileViewType myType = (ProfileViewType) type;
        if (myType == ProfileViewType.TYPE_HEAD) {
            return new ProfileHeadItemView();
        } else if (myType == ProfileViewType.TYPE_SECTION_HEAD) {
            return new SectionHeadView();
        } else if (myType == ProfileViewType.TYPE_COMMON_ITEM) {
            return new ProfileCommon();
        } else if (myType == ProfileViewType.TYPE_SWITCH) {
            return new ProfileSwitch();
        } else if (myType == ProfileViewType.TYPE_EXIST) {
            return new ProfileExist();
        }
        return new SectionHeadView();

    }
}
